﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Resources;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Salamanca.DataAccess;
using Salamanca.DataAccess.EnterpriseLibrary.Data;
using Salamanca.DataAccess.Collections;
using Salamanca.DataRules;

namespace Sevesc.Sps.DomainModel.Mappers.EnterpriseLibrary
{



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="LieuDeService" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class LieuDeServiceMapper:
        DataMapper<LieuDeService, LieuDeService.PrimaryKey, LieuDeService.DataTransfer>,
        ILieuDeServiceMapper
    {

        /// <summary />
        public LieuDeServiceMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<LieuDeService>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="LieuDeService" /> instances.</summary>
        public DomainEntityKeyedCollection<LieuDeService> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("LieuDeServiceSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="LieuDeService" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuDeService> FindByClient(Personne entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceSelectByClient", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="LieuDeService" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuDeService> FindByContacts(Personne entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceSelectByContacts", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="LieuDeService" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuDeService> FindByAdresse(Adresse entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceSelectByAdresse", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="LieuDeService" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuDeService> FindByContrats(Contrat entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceSelectByContrats", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(LieuDeService.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(LieuDeService.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(LieuDeService.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(LieuDeService.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override LieuDeService.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            LieuDeService.DataTransfer data=new LieuDeService.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(LieuDeService entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static LieuDeService.DataTransfer FillData(LieuDeService.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Client_Id");
                if (!record.IsDBNull(ord))
                    data.Client_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Adresse_Id");
                if (!record.IsDBNull(ord))
                    data.Adresse_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Risque");
                if (!record.IsDBNull(ord))
                    data.Risque=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Localisation");
                if (!record.IsDBNull(ord))
                    data.Localisation=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, LieuDeService.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, LieuDeService.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, LieuDeService.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Client_Id ?? (object)DBNull.Value,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                data.Statut,
                data.Risque,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, LieuDeService.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuDeServiceUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Client_Id ?? (object)DBNull.Value,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                data.Statut,
                data.Risque,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="LieuxDeServiceContrats" /> association entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    internal partial class LieuxDeServiceContratsMapper:
        DataMapper<LieuxDeServiceContrats, LieuxDeServiceContrats.PrimaryKey, LieuxDeServiceContrats.DataTransfer>,
        ILieuxDeServiceContratsMapper
    {

        /// <summary />
        public LieuxDeServiceContratsMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<LieuxDeServiceContrats>(), cacheManager)
        {
        }

        /// <summary>Returns the <see cref="LieuxDeServiceContrats" /> association instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuxDeServiceContrats> FindByContrat(Contrat entity, DataMapperCollection dataMappers)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuxDeServiceContratsSelectByContrat", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(new DbCommand[] { command }, dataMappers);
        }

        /// <summary>Returns the <see cref="LieuxDeServiceContrats" /> association instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<LieuxDeServiceContrats> FindByLieuDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuxDeServiceContratsSelectByLieuDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(new DbCommand[] { command }, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(LieuxDeServiceContrats.PrimaryKey key)
        {
/*            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuxDeServiceContratsSelect", CultureInfo.InvariantCulture),
                data.LieuDeService_Id,
                data.Contrat_Id
            );

            return new DbCommand[] { command };
*/
            throw new InvalidOperationException("An association entity cannot be selected.");
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(LieuxDeServiceContrats.DataTransfer data)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuxDeServiceContratsDelete", CultureInfo.InvariantCulture),
                data.LieuDeService_Id,
                data.Contrat_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(LieuxDeServiceContrats.DataTransfer data)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("LieuxDeServiceContratsInsert", CultureInfo.InvariantCulture),
                data.LieuDeService_Id,
                data.Contrat_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(LieuxDeServiceContrats.DataTransfer data)
        {
            throw new InvalidOperationException("An association entity cannot be updated.");
        }

        /// <summary />
        protected override LieuxDeServiceContrats.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            LieuxDeServiceContrats.DataTransfer data=new LieuxDeServiceContrats.DataTransfer();

            {
                int ord=records[0].GetOrdinal("LieuDeService_Id");
                if (!records[0].IsDBNull(ord))
                    data.LieuDeService_Id=records[0].GetGuid(ord);
            }

            {
                int ord=records[0].GetOrdinal("Contrat_Id");
                if (!records[0].IsDBNull(ord))
                    data.Contrat_Id=records[0].GetGuid(ord);
            }

            return data;
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Contrat" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class ContratMapper:
        DataMapper<Contrat, Contrat.PrimaryKey, Contrat.DataTransfer>,
        IContratMapper
    {

        /// <summary />
        public ContratMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Contrat>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Contrat" /> instances.</summary>
        public DomainEntityKeyedCollection<Contrat> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("ContratSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Contrat" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Contrat> FindByLieuxDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContratSelectByLieuxDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Contrat.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Contrat.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Contrat.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Contrat.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Contrat.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Contrat.DataTransfer data=new Contrat.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Contrat entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Contrat.DataTransfer FillData(Contrat.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("TypeContrat");
                if (!record.IsDBNull(ord))
                    data.TypeContrat=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Domaine");
                if (!record.IsDBNull(ord))
                    data.Domaine=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Contrat.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContratSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Contrat.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContratDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Contrat.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContratInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.TypeContrat ?? (object)DBNull.Value,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.Domaine ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Contrat.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContratUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.TypeContrat ?? (object)DBNull.Value,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.Domaine ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Convention" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class ConventionMapper:
        DataMapper<Convention, Convention.PrimaryKey, Convention.DataTransfer>,
        IConventionMapper
    {

        /// <summary />
        public ConventionMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Convention>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Convention" /> instances.</summary>
        public DomainEntityKeyedCollection<Convention> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("ConventionSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Convention" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Convention> FindByLieuDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionSelectByLieuDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Convention" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Convention> FindByGestionnaire(Personne entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionSelectByGestionnaire", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Convention.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Convention.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Convention.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Convention.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Convention.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Convention.DataTransfer data=new Convention.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        internal static Convention.DataTransfer FillData(Convention.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("LieuDeService_Id");
                if (!record.IsDBNull(ord))
                    data.LieuDeService_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Gestionnaire_Id");
                if (!record.IsDBNull(ord))
                    data.Gestionnaire_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Numero");
                if (!record.IsDBNull(ord))
                    data.Numero=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DateSignature");
                if (!record.IsDBNull(ord))
                    data.DateSignature=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Montant");
                if (!record.IsDBNull(ord))
                    data.Montant=record.GetInt32(ord);
            }

            {
                int ord=record.GetOrdinal("Remise");
                if (!record.IsDBNull(ord))
                    data.Remise=record.GetInt32(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Convention.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Convention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionDelete", CultureInfo.InvariantCulture),
                data.Numero
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Convention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionInsert", CultureInfo.InvariantCulture),
                data.Numero,
                data.Id,
                data.LieuDeService_Id,
                data.Gestionnaire_Id,
                data.Statut,
                (object)data.DateSignature ?? (object)DBNull.Value,
                (object)data.Montant ?? (object)DBNull.Value,
                (object)data.Remise ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Convention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ConventionUpdate", CultureInfo.InvariantCulture),
                data.Numero,
                data.Id,
                data.LieuDeService_Id,
                data.Gestionnaire_Id,
                data.Statut,
                (object)data.DateSignature ?? (object)DBNull.Value,
                (object)data.Montant ?? (object)DBNull.Value,
                (object)data.Remise ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Personne" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class PersonneMapper:
        DataMapper<Personne, Personne.PrimaryKey, Personne.DataTransfer>,
        IPersonneMapper
    {

        /// <summary />
        public PersonneMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Personne>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Personne" /> instances.</summary>
        public DomainEntityKeyedCollection<Personne> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("PersonneSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Personne" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Personne> FindByAdresse(Adresse entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneSelectByAdresse", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Personne" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Personne> FindByLieuDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneSelectByLieuDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Personne.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Personne.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Personne.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Personne.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Personne.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Personne.DataTransfer data=new Personne.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Personne entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Personne.DataTransfer FillData(Personne.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Adresse_Id");
                if (!record.IsDBNull(ord))
                    data.Adresse_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Titre");
                if (!record.IsDBNull(ord))
                    data.Titre=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("TphFixe");
                if (!record.IsDBNull(ord))
                    data.TphFixe=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("TphPortable");
                if (!record.IsDBNull(ord))
                    data.TphPortable=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("TphBureau");
                if (!record.IsDBNull(ord))
                    data.TphBureau=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Fax");
                if (!record.IsDBNull(ord))
                    data.Fax=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Fax2");
                if (!record.IsDBNull(ord))
                    data.Fax2=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Mail");
                if (!record.IsDBNull(ord))
                    data.Mail=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Personne.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Personne.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Personne.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                data.Nom,
                (object)data.Titre ?? (object)DBNull.Value,
                (object)data.TphFixe ?? (object)DBNull.Value,
                (object)data.TphPortable ?? (object)DBNull.Value,
                (object)data.TphBureau ?? (object)DBNull.Value,
                (object)data.Fax ?? (object)DBNull.Value,
                (object)data.Fax2 ?? (object)DBNull.Value,
                (object)data.Mail ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Personne.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("PersonneUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                data.Nom,
                (object)data.Titre ?? (object)DBNull.Value,
                (object)data.TphFixe ?? (object)DBNull.Value,
                (object)data.TphPortable ?? (object)DBNull.Value,
                (object)data.TphBureau ?? (object)DBNull.Value,
                (object)data.Fax ?? (object)DBNull.Value,
                (object)data.Fax2 ?? (object)DBNull.Value,
                (object)data.Mail ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Compteur" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class CompteurMapper:
        DataMapper<Compteur, Compteur.PrimaryKey, Compteur.DataTransfer>,
        ICompteurMapper
    {

        /// <summary />
        public CompteurMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Compteur>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Compteur" /> instances.</summary>
        public DomainEntityKeyedCollection<Compteur> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("CompteurSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Compteur" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Compteur> FindByLieuDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurSelectByLieuDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Compteur" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Compteur> FindByBranchement(Branchement entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurSelectByBranchement", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Compteur" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Compteur> FindByAdresse(Adresse entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurSelectByAdresse", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Compteur.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Compteur.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Compteur.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Compteur.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Compteur.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Compteur.DataTransfer data=new Compteur.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Compteur entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Compteur.DataTransfer FillData(Compteur.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("LieuDeService_Id");
                if (!record.IsDBNull(ord))
                    data.LieuDeService_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Branchement_Id");
                if (!record.IsDBNull(ord))
                    data.Branchement_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Adresse_Id");
                if (!record.IsDBNull(ord))
                    data.Adresse_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("CodeGn");
                if (!record.IsDBNull(ord))
                    data.CodeGn=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Numero");
                if (!record.IsDBNull(ord))
                    data.Numero=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Diametre");
                if (!record.IsDBNull(ord))
                    data.Diametre=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Marque");
                if (!record.IsDBNull(ord))
                    data.Marque=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Modele");
                if (!record.IsDBNull(ord))
                    data.Modele=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Localisation");
                if (!record.IsDBNull(ord))
                    data.Localisation=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Compteur.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Compteur.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Compteur.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.LieuDeService_Id,
                data.Branchement_Id,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                (object)data.CodeGn ?? (object)DBNull.Value,
                (object)data.Numero ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Marque ?? (object)DBNull.Value,
                (object)data.Modele ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Compteur.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CompteurUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.LieuDeService_Id,
                data.Branchement_Id,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                (object)data.CodeGn ?? (object)DBNull.Value,
                (object)data.Numero ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Marque ?? (object)DBNull.Value,
                (object)data.Modele ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Branchement" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class BranchementMapper:
        DataMapper<Branchement, Branchement.PrimaryKey, Branchement.DataTransfer>,
        IBranchementMapper
    {

        /// <summary />
        public BranchementMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Branchement>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Branchement" /> instances.</summary>
        public DomainEntityKeyedCollection<Branchement> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("BranchementSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Branchement" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Branchement> FindByPersonne(Personne entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementSelectByPersonne", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Branchement" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Branchement> FindByAdresse(Adresse entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementSelectByAdresse", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Branchement.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Branchement.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Branchement.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Branchement.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Branchement.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Branchement.DataTransfer data=new Branchement.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Branchement entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Branchement.DataTransfer FillData(Branchement.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Personne_Id");
                if (!record.IsDBNull(ord))
                    data.Personne_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Adresse_Id");
                if (!record.IsDBNull(ord))
                    data.Adresse_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("CodeGn");
                if (!record.IsDBNull(ord))
                    data.CodeGn=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Materiau");
                if (!record.IsDBNull(ord))
                    data.Materiau=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Diametre");
                if (!record.IsDBNull(ord))
                    data.Diametre=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Emplacement");
                if (!record.IsDBNull(ord))
                    data.Emplacement=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Localisation");
                if (!record.IsDBNull(ord))
                    data.Localisation=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Branchement.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Branchement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Branchement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Personne_Id ?? (object)DBNull.Value,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                (object)data.CodeGn ?? (object)DBNull.Value,
                (object)data.Materiau ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Emplacement ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Branchement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BranchementUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Personne_Id ?? (object)DBNull.Value,
                (object)data.Adresse_Id ?? (object)DBNull.Value,
                (object)data.CodeGn ?? (object)DBNull.Value,
                (object)data.Materiau ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Emplacement ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Volume" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class VolumeMapper:
        DataMapper<Volume, Volume.PrimaryKey, Volume.DataTransfer>,
        IVolumeMapper
    {

        /// <summary />
        public VolumeMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Volume>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Volume" /> instances.</summary>
        public DomainEntityKeyedCollection<Volume> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("VolumeSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Volume" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Volume> FindByCompteur(Compteur entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VolumeSelectByCompteur", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Volume.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Volume.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Volume.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Volume.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Volume.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Volume.DataTransfer data=new Volume.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Volume entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Volume.DataTransfer FillData(Volume.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Compteur_Id");
                if (!record.IsDBNull(ord))
                    data.Compteur_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("DateValeur");
                if (!record.IsDBNull(ord))
                    data.DateValeur=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Valeur");
                if (!record.IsDBNull(ord))
                    data.Valeur=record.GetInt64(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Volume.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VolumeSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Volume.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VolumeDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Volume.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VolumeInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Compteur_Id,
                (object)data.DateValeur ?? (object)DBNull.Value,
                (object)data.Valeur ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Volume.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VolumeUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Compteur_Id,
                (object)data.DateValeur ?? (object)DBNull.Value,
                (object)data.Valeur ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Equipement" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class EquipementMapper:
        DataMapper<Equipement, Equipement.PrimaryKey, Equipement.DataTransfer>,
        IEquipementMapper
    {

        /// <summary />
        public EquipementMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Equipement>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Equipement" /> instances.</summary>
        public DomainEntityKeyedCollection<Equipement> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("EquipementSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Equipement" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Equipement> FindByCompteur(Compteur entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EquipementSelectByCompteur", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Equipement.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Equipement.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Equipement.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Equipement.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Equipement.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Equipement.DataTransfer data=new Equipement.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Equipement entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Equipement.DataTransfer FillData(Equipement.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Compteur_Id");
                if (!record.IsDBNull(ord))
                    data.Compteur_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("TypeEquipement");
                if (!record.IsDBNull(ord))
                    data.TypeEquipement=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Diametre");
                if (!record.IsDBNull(ord))
                    data.Diametre=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Marque");
                if (!record.IsDBNull(ord))
                    data.Marque=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Modele");
                if (!record.IsDBNull(ord))
                    data.Modele=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Numero");
                if (!record.IsDBNull(ord))
                    data.Numero=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Rang");
                if (!record.IsDBNull(ord))
                    data.Rang=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DatePose");
                if (!record.IsDBNull(ord))
                    data.DatePose=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Localisation");
                if (!record.IsDBNull(ord))
                    data.Localisation=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Conventionne");
                if (!record.IsDBNull(ord))
                    data.Conventionne=record.GetBoolean(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Equipement.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EquipementSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Equipement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EquipementDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Equipement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EquipementInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Compteur_Id,
                (object)data.TypeEquipement ?? (object)DBNull.Value,
                (object)data.Statut ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Marque ?? (object)DBNull.Value,
                (object)data.Modele ?? (object)DBNull.Value,
                (object)data.Numero ?? (object)DBNull.Value,
                data.Rang,
                (object)data.DatePose ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                (object)data.Conventionne ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Equipement.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EquipementUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Compteur_Id,
                (object)data.TypeEquipement ?? (object)DBNull.Value,
                (object)data.Statut ?? (object)DBNull.Value,
                (object)data.Diametre ?? (object)DBNull.Value,
                (object)data.Marque ?? (object)DBNull.Value,
                (object)data.Modele ?? (object)DBNull.Value,
                (object)data.Numero ?? (object)DBNull.Value,
                data.Rang,
                (object)data.DatePose ?? (object)DBNull.Value,
                (object)data.Localisation ?? (object)DBNull.Value,
                (object)data.Conventionne ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Dossier" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class DossierMapper:
        DataMapper<Dossier, Dossier.PrimaryKey, Dossier.DataTransfer>,
        IDossierMapper
    {

        /// <summary />
        public DossierMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Dossier>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Dossier" /> instances.</summary>
        public DomainEntityKeyedCollection<Dossier> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("DossierSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Dossier" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Dossier> FindByLieuDeService(LieuDeService entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierSelectByLieuDeService", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Dossier" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Dossier> FindByProgramme(Programme entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierSelectByProgramme", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Dossier.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Dossier.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Dossier.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Dossier.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Dossier.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Dossier.DataTransfer data=new Dossier.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Dossier entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Dossier.DataTransfer FillData(Dossier.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("LieuDeService_Id");
                if (!record.IsDBNull(ord))
                    data.LieuDeService_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Programme_Id");
                if (!record.IsDBNull(ord))
                    data.Programme_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("TypeDossier");
                if (!record.IsDBNull(ord))
                    data.TypeDossier=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DateOuverture");
                if (!record.IsDBNull(ord))
                    data.DateOuverture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Delai");
                if (!record.IsDBNull(ord))
                    data.Delai=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateCloture");
                if (!record.IsDBNull(ord))
                    data.DateCloture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Commentaire");
                if (!record.IsDBNull(ord))
                    data.Commentaire=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Dossier.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Dossier.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Dossier.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.LieuDeService_Id,
                (object)data.Programme_Id ?? (object)DBNull.Value,
                (object)data.TypeDossier ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateCloture ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Dossier.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DossierUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.LieuDeService_Id,
                (object)data.Programme_Id ?? (object)DBNull.Value,
                (object)data.TypeDossier ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateCloture ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Programme" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class ProgrammeMapper:
        DataMapper<Programme, Programme.PrimaryKey, Programme.DataTransfer>,
        IProgrammeMapper
    {

        /// <summary />
        public ProgrammeMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Programme>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Programme" /> instances.</summary>
        public DomainEntityKeyedCollection<Programme> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("ProgrammeSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }


        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Programme.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Programme.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Programme.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Programme.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Programme.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Programme.DataTransfer data=new Programme.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Programme entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Programme.DataTransfer FillData(Programme.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("TypeProgramme");
                if (!record.IsDBNull(ord))
                    data.TypeProgramme=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DateOuverture");
                if (!record.IsDBNull(ord))
                    data.DateOuverture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Delai");
                if (!record.IsDBNull(ord))
                    data.Delai=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateCloture");
                if (!record.IsDBNull(ord))
                    data.DateCloture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Commentaire");
                if (!record.IsDBNull(ord))
                    data.Commentaire=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Programme.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ProgrammeSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Programme.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ProgrammeDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Programme.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ProgrammeInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                data.TypeProgramme,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateCloture ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Programme.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ProgrammeUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                data.TypeProgramme,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateCloture ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Etape" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class EtapeMapper:
        DataMapper<Etape, Etape.PrimaryKey, Etape.DataTransfer>,
        IEtapeMapper
    {

        /// <summary />
        public EtapeMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Etape>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Etape" /> instances.</summary>
        public DomainEntityKeyedCollection<Etape> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("EtapeSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Etape" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Etape> FindByDossier(Dossier entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EtapeSelectByDossier", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Etape.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Etape.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Etape.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Etape.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Etape.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Etape.DataTransfer data=new Etape.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Etape entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Etape.DataTransfer FillData(Etape.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Dossier_Id");
                if (!record.IsDBNull(ord))
                    data.Dossier_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("TypeEtape");
                if (!record.IsDBNull(ord))
                    data.TypeEtape=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DatePlanification");
                if (!record.IsDBNull(ord))
                    data.DatePlanification=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateOuverture");
                if (!record.IsDBNull(ord))
                    data.DateOuverture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Delai");
                if (!record.IsDBNull(ord))
                    data.Delai=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateRealisation");
                if (!record.IsDBNull(ord))
                    data.DateRealisation=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Commentaire");
                if (!record.IsDBNull(ord))
                    data.Commentaire=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Etape.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EtapeSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Etape.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EtapeDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Etape.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EtapeInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Dossier_Id,
                data.TypeEtape,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Etape.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("EtapeUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Dossier_Id,
                data.TypeEtape,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Action" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class ActionMapper:
        DataMapper<Action, Action.PrimaryKey, Action.DataTransfer>,
        IActionMapper
    {

        /// <summary />
        public ActionMapper(Database database, ICacheManager cacheManager):
            base(database, ActionInstanceCreator, cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Action" /> instances.</summary>
        public DomainEntityKeyedCollection<Action> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("ActionSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Action" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Action> FindByEtape(Etape entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionSelectByEtape", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }
        /// <summary>Returns the <see cref="Action" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Action> FindByDocuments(Document entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionSelectByDocuments", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Action.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Action.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Action.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Action.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Action.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Action.DataTransfer data=CreateData(records[0]);

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Action entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        public static DomainEntityCreator<Action> ActionInstanceCreator
        {
            get
            {
                return new DomainEntityCreator<Action>(
                    new DomainEntityCreateHandler<Action>(
                        CreateInstance
                    )
                );
            }
        }

        /// <summary />
        private static Action CreateInstance(IDataTransferObject data)
        {
            switch (((Action.DataTransfer)data).Type)
            {
            case "Action":
                return new Action();
            case "Intervention":
                return new Intervention();
            }

            throw new InvalidOperationException();
        }

        internal static Action.DataTransfer CreateData(IDataRecord record)
        {
            int i=record.GetOrdinal("Type");
            if (!record.IsDBNull(i))
                switch (record.GetString(i))
                {
                case "Action":
                    return ActionMapper.FillData(new Action.DataTransfer(), record);
                case "Intervention":
                    return InterventionMapper.FillData(new Intervention.DataTransfer(), record);
                }

            throw new InvalidOperationException("Unknown entity type.");
        }

        /// <summary />
        internal static Action.DataTransfer FillData(Action.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Etape_Id");
                if (!record.IsDBNull(ord))
                    data.Etape_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("TypeAction");
                if (!record.IsDBNull(ord))
                    data.TypeAction=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("DatePlanification");
                if (!record.IsDBNull(ord))
                    data.DatePlanification=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateOuverture");
                if (!record.IsDBNull(ord))
                    data.DateOuverture=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Acteur");
                if (!record.IsDBNull(ord))
                    data.Acteur=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Delai");
                if (!record.IsDBNull(ord))
                    data.Delai=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("DateRealisation");
                if (!record.IsDBNull(ord))
                    data.DateRealisation=record.GetDateTime(ord);
            }

            {
                int ord=record.GetOrdinal("Statut");
                if (!record.IsDBNull(ord))
                    data.Statut=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Commentaire");
                if (!record.IsDBNull(ord))
                    data.Commentaire=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Action.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Action.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Action.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Etape_Id,
                data.TypeAction,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Acteur ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Action.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Etape_Id,
                data.TypeAction,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Acteur ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="ActionsDocuments" /> association entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    internal partial class ActionsDocumentsMapper:
        DataMapper<ActionsDocuments, ActionsDocuments.PrimaryKey, ActionsDocuments.DataTransfer>,
        IActionsDocumentsMapper
    {

        /// <summary />
        public ActionsDocumentsMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<ActionsDocuments>(), cacheManager)
        {
        }

        /// <summary>Returns the <see cref="ActionsDocuments" /> association instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<ActionsDocuments> FindByDocument(Document entity, DataMapperCollection dataMappers)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionsDocumentsSelectByDocument", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(new DbCommand[] { command }, dataMappers);
        }

        /// <summary>Returns the <see cref="ActionsDocuments" /> association instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<ActionsDocuments> FindByAction(Action entity, DataMapperCollection dataMappers)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionsDocumentsSelectByAction", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(new DbCommand[] { command }, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(ActionsDocuments.PrimaryKey key)
        {
/*            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionsDocumentsSelect", CultureInfo.InvariantCulture),
                data.Action_Id,
                data.Document_Id
            );

            return new DbCommand[] { command };
*/
            throw new InvalidOperationException("An association entity cannot be selected.");
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(ActionsDocuments.DataTransfer data)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionsDocumentsDelete", CultureInfo.InvariantCulture),
                data.Action_Id,
                data.Document_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(ActionsDocuments.DataTransfer data)
        {
            DbCommand command=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ActionsDocumentsInsert", CultureInfo.InvariantCulture),
                data.Action_Id,
                data.Document_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(ActionsDocuments.DataTransfer data)
        {
            throw new InvalidOperationException("An association entity cannot be updated.");
        }

        /// <summary />
        protected override ActionsDocuments.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            ActionsDocuments.DataTransfer data=new ActionsDocuments.DataTransfer();

            {
                int ord=records[0].GetOrdinal("Action_Id");
                if (!records[0].IsDBNull(ord))
                    data.Action_Id=records[0].GetGuid(ord);
            }

            {
                int ord=records[0].GetOrdinal("Document_Id");
                if (!records[0].IsDBNull(ord))
                    data.Document_Id=records[0].GetGuid(ord);
            }

            return data;
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Document" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class DocumentMapper:
        DataMapper<Document, Document.PrimaryKey, Document.DataTransfer>,
        IDocumentMapper
    {

        /// <summary />
        public DocumentMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Document>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Document" /> instances.</summary>
        public DomainEntityKeyedCollection<Document> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("DocumentSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Document" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Document> FindByActions(Action entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DocumentSelectByActions", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Document.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Document.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Document.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Document.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Document.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Document.DataTransfer data=new Document.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Document entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Document.DataTransfer FillData(Document.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Donnees");
                if (!record.IsDBNull(ord))
                    data.Donnees=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Fichier");
                if (!record.IsDBNull(ord))
                    data.Fichier=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Document.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DocumentSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Document.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DocumentDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Document.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DocumentInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.Donnees ?? (object)DBNull.Value,
                (object)data.Fichier ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Document.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("DocumentUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.Donnees ?? (object)DBNull.Value,
                (object)data.Fichier ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Intervention" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class InterventionMapper:
        DataMapper<Intervention, Action.PrimaryKey, Action.DataTransfer>,
        IInterventionMapper
    {

        /// <summary />
        public InterventionMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Intervention>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Intervention" /> instances.</summary>
        public DomainEntityKeyedCollection<Intervention> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("InterventionSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Intervention" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Intervention> FindByEquipement(Equipement entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("InterventionSelectByEquipement", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Intervention.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Action.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, (Intervention.DataTransfer)data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Action.DataTransfer data)
        {
            return _CreateInsertCommands(Database, (Intervention.DataTransfer)data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Action.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, (Intervention.DataTransfer)data);
        }

        /// <summary />
        protected override Action.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Intervention.DataTransfer data=new Intervention.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Intervention entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Intervention.DataTransfer FillData(Intervention.DataTransfer data, IDataRecord record)
        {
            ActionMapper.FillData(data, record);

            {
                int ord=record.GetOrdinal("Equipement_Id");
                if (!record.IsDBNull(ord))
                    data.Equipement_Id=record.GetGuid(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Intervention.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("InterventionSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Intervention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("InterventionDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Intervention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("InterventionInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Etape_Id,
                data.TypeAction,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Acteur ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value,
                data.Equipement_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Intervention.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("InterventionUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Etape_Id,
                data.TypeAction,
                (object)data.DatePlanification ?? (object)DBNull.Value,
                (object)data.DateOuverture ?? (object)DBNull.Value,
                (object)data.Acteur ?? (object)DBNull.Value,
                (object)data.Delai ?? (object)DBNull.Value,
                (object)data.DateRealisation ?? (object)DBNull.Value,
                data.Statut,
                (object)data.Commentaire ?? (object)DBNull.Value,
                data.Equipement_Id
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Adresse" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class AdresseMapper:
        DataMapper<Adresse, Adresse.PrimaryKey, Adresse.DataTransfer>,
        IAdresseMapper
    {

        /// <summary />
        public AdresseMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Adresse>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Adresse" /> instances.</summary>
        public DomainEntityKeyedCollection<Adresse> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("AdresseSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Adresse" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Adresse> FindByVoie(Voie entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("AdresseSelectByVoie", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Adresse.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Adresse.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Adresse.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Adresse.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Adresse.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Adresse.DataTransfer data=new Adresse.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Adresse entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Adresse.DataTransfer FillData(Adresse.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Voie_Id");
                if (!record.IsDBNull(ord))
                    data.Voie_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Numero");
                if (!record.IsDBNull(ord))
                    data.Numero=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Complement");
                if (!record.IsDBNull(ord))
                    data.Complement=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Adresse.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("AdresseSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Adresse.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("AdresseDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Adresse.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("AdresseInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Voie_Id,
                (object)data.Numero ?? (object)DBNull.Value,
                (object)data.Complement ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Adresse.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("AdresseUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Voie_Id,
                (object)data.Numero ?? (object)DBNull.Value,
                (object)data.Complement ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Voie" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class VoieMapper:
        DataMapper<Voie, Voie.PrimaryKey, Voie.DataTransfer>,
        IVoieMapper
    {

        /// <summary />
        public VoieMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Voie>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Voie" /> instances.</summary>
        public DomainEntityKeyedCollection<Voie> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("VoieSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }

        /// <summary>Returns the <see cref="Voie" /> instances that are related to the specified entity.</summary>
        public DomainEntityKeyedCollection<Voie> FindByCommune(Commune entity, DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VoieSelectByCommune", CultureInfo.InvariantCulture),
                entity.GetId().Value
            );

            return Load(commands, dataMappers);
        }

        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Voie.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Voie.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Voie.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Voie.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Voie.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Voie.DataTransfer data=new Voie.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Voie entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Voie.DataTransfer FillData(Voie.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Commune_Id");
                if (!record.IsDBNull(ord))
                    data.Commune_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Voie.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VoieSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Voie.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VoieDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Voie.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VoieInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.Commune_Id,
                (object)data.Nom ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Voie.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("VoieUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.Commune_Id,
                (object)data.Nom ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Commune" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class CommuneMapper:
        DataMapper<Commune, Commune.PrimaryKey, Commune.DataTransfer>,
        ICommuneMapper
    {

        /// <summary />
        public CommuneMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Commune>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Commune" /> instances.</summary>
        public DomainEntityKeyedCollection<Commune> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("CommuneSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }


        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Commune.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Commune.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Commune.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Commune.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Commune.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Commune.DataTransfer data=new Commune.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Commune entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Commune.DataTransfer FillData(Commune.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Nom");
                if (!record.IsDBNull(ord))
                    data.Nom=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("CodePostal");
                if (!record.IsDBNull(ord))
                    data.CodePostal=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("CodeInsee");
                if (!record.IsDBNull(ord))
                    data.CodeInsee=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Actif");
                if (!record.IsDBNull(ord))
                    data.Actif=record.GetBoolean(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Commune.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CommuneSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Commune.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CommuneDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Commune.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CommuneInsert", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.CodePostal ?? (object)DBNull.Value,
                (object)data.CodeInsee ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Commune.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("CommuneUpdate", CultureInfo.InvariantCulture),
                data.Id,
                (object)data.Nom ?? (object)DBNull.Value,
                (object)data.CodePostal ?? (object)DBNull.Value,
                (object)data.CodeInsee ?? (object)DBNull.Value,
                data.Actif
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Bordereau" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class BordereauMapper:
        DataMapper<Bordereau, Bordereau.PrimaryKey, Bordereau.DataTransfer>,
        IBordereauMapper
    {

        /// <summary />
        public BordereauMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Bordereau>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Bordereau" /> instances.</summary>
        public DomainEntityKeyedCollection<Bordereau> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("BordereauSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }


        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Bordereau.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Bordereau.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Bordereau.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Bordereau.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Bordereau.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Bordereau.DataTransfer data=new Bordereau.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        protected override void OnInserting(Bordereau entity, IList<DbCommand> commands)
        {
            entity.SetId(Guid.NewGuid());

            base.OnInserting(entity, commands);
        }

        /// <summary />
        internal static Bordereau.DataTransfer FillData(Bordereau.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Id");
                if (!record.IsDBNull(ord))
                    data.Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("CodePharos");
                if (!record.IsDBNull(ord))
                    data.CodePharos=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("Libelle");
                if (!record.IsDBNull(ord))
                    data.Libelle=record.GetString(ord);
            }

            {
                int ord=record.GetOrdinal("PrixUnitaire");
                if (!record.IsDBNull(ord))
                    data.PrixUnitaire=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Bordereau.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BordereauSelect", CultureInfo.InvariantCulture),
                key.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Bordereau.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BordereauDelete", CultureInfo.InvariantCulture),
                data.Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Bordereau.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BordereauInsert", CultureInfo.InvariantCulture),
                data.Id,
                data.CodePharos,
                data.Libelle,
                data.PrixUnitaire
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Bordereau.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("BordereauUpdate", CultureInfo.InvariantCulture),
                data.Id,
                data.CodePharos,
                data.Libelle,
                data.PrixUnitaire
            );

            return new DbCommand[] { command };
        }
    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary>A <see cref="IDataMapper">Data Mapper</see> that maps a <see cref="Contact" /> entity to a database.</summary>
    ///
    ////////////////////////////////////////////////////////////////////////////

    public partial class ContactMapper:
        DataMapper<Contact, Contact.PrimaryKey, Contact.DataTransfer>,
        IContactMapper
    {

        /// <summary />
        public ContactMapper(Database database, ICacheManager cacheManager):
            base(database, DomainEntityCreator.CreateDefault<Contact>(), cacheManager)
        {
        }

        /// <summary>Returns all the <see cref="Contact" /> instances.</summary>
        public DomainEntityKeyedCollection<Contact> FindAll(DataMapperCollection dataMappers)
        {
            DbCommand[] commands=new DbCommand[1];

            commands[0]=Database.GetStoredProcCommand(SqlResource.Manager.GetString("ContactSelectAll", CultureInfo.InvariantCulture));

            return Load(commands, dataMappers);
        }


        /// <summary />
        protected override IList<DbCommand> CreateSelectCommands(Contact.PrimaryKey key)
        {
            return _CreateSelectCommands(Database, key);
        }

        /// <summary />
        protected override IList<DbCommand> CreateDeleteCommands(Contact.DataTransfer data)
        {
            return _CreateDeleteCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateInsertCommands(Contact.DataTransfer data)
        {
            return _CreateInsertCommands(Database, data);
        }

        /// <summary />
        protected override IList<DbCommand> CreateUpdateCommands(Contact.DataTransfer data)
        {
            return _CreateUpdateCommands(Database, data);
        }

        /// <summary />
        protected override Contact.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
            Contact.DataTransfer data=new Contact.DataTransfer();

            return FillData(data, records[0]);
        }

        /// <summary />
        internal static Contact.DataTransfer FillData(Contact.DataTransfer data, IDataRecord record)
        {
            {
                int ord=record.GetOrdinal("Personne_Id");
                if (!record.IsDBNull(ord))
                    data.Personne_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("LieuDeService_Id");
                if (!record.IsDBNull(ord))
                    data.LieuDeService_Id=record.GetGuid(ord);
            }

            {
                int ord=record.GetOrdinal("Description");
                if (!record.IsDBNull(ord))
                    data.Description=record.GetString(ord);
            }

            return data;
        }

        /// <summary />
        internal static IList<DbCommand> _CreateSelectCommands(Database database, Contact.PrimaryKey key)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContactSelect", CultureInfo.InvariantCulture),
                key.Value.Personne_Id,
                key.Value.LieuDeService_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateDeleteCommands(Database database, Contact.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContactDelete", CultureInfo.InvariantCulture),
                data.Personne_Id,
                data.LieuDeService_Id
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateInsertCommands(Database database, Contact.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContactInsert", CultureInfo.InvariantCulture),
                data.Personne_Id,
                data.LieuDeService_Id,
                (object)data.Description ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }

        /// <summary />
        internal static IList<DbCommand> _CreateUpdateCommands(Database database, Contact.DataTransfer data)
        {
            DbCommand command=database.GetStoredProcCommand(
                SqlResource.Manager.GetString("ContactUpdate", CultureInfo.InvariantCulture),
                data.Personne_Id,
                data.LieuDeService_Id,
                (object)data.Description ?? (object)DBNull.Value
            );

            return new DbCommand[] { command };
        }
    }



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ///////////////////////////////////////////////////////////////////////////

    public static partial class Mappers
    {

        /// <summary />
        internal static object ExecuteScalar(Database db, DbCommand command, DbTransaction transaction)
        {
            if (transaction!=null)
                return db.ExecuteScalar(command, transaction);
            return db.ExecuteScalar(command);
        }

        /// <summary />
        internal static IDataReader ExecuteReader(Database db, DbCommand command, DbTransaction transaction)
        {
            if (transaction!=null)
                return db.ExecuteReader(command, transaction);
            return db.ExecuteReader(command);
        }

        /// <summary />
        public static DataMapperCollection CreateDataMapperCollection(Database database, ICacheManager cacheManager/*, bool localTransactions*/)
        {
            DataMapperCollection ret = new DataMapperCollection();

            ret.Add(typeof(LieuDeService), new LieuDeServiceMapper(database, cacheManager));
            ret.Add(typeof(LieuxDeServiceContrats), new LieuxDeServiceContratsMapper(database, cacheManager));
            ret.Add(typeof(Contrat), new ContratMapper(database, cacheManager));
            ret.Add(typeof(Convention), new ConventionMapper(database, cacheManager));
            ret.Add(typeof(Personne), new PersonneMapper(database, cacheManager));
            ret.Add(typeof(Compteur), new CompteurMapper(database, cacheManager));
            ret.Add(typeof(Branchement), new BranchementMapper(database, cacheManager));
            ret.Add(typeof(Volume), new VolumeMapper(database, cacheManager));
            ret.Add(typeof(Equipement), new EquipementMapper(database, cacheManager));
            ret.Add(typeof(Dossier), new DossierMapper(database, cacheManager));
            ret.Add(typeof(Programme), new ProgrammeMapper(database, cacheManager));
            ret.Add(typeof(Etape), new EtapeMapper(database, cacheManager));
            ret.Add(typeof(Action), new ActionMapper(database, cacheManager));
            ret.Add(typeof(ActionsDocuments), new ActionsDocumentsMapper(database, cacheManager));
            ret.Add(typeof(Document), new DocumentMapper(database, cacheManager));
            ret.Add(typeof(Intervention), new InterventionMapper(database, cacheManager));
            ret.Add(typeof(Adresse), new AdresseMapper(database, cacheManager));
            ret.Add(typeof(Voie), new VoieMapper(database, cacheManager));
            ret.Add(typeof(Commune), new CommuneMapper(database, cacheManager));
            ret.Add(typeof(Bordereau), new BordereauMapper(database, cacheManager));
            ret.Add(typeof(Contact), new ContactMapper(database, cacheManager));

//            if (localTransactions)
//                ret.PersistenceProvider=new PersistenceProvider(database);

            return ret;
        }

    }



    ////////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ////////////////////////////////////////////////////////////////////////////

    internal static class SqlResource
    {

        /// <summary />
        public static ResourceManager Manager
        {
            get
            {
                if (_Manager==null)
                    _Manager=new ResourceManager("Sevesc.Sps.DomainModel.GeneratedCode.SqlResource", typeof(SqlResource).Assembly);
                return _Manager;
            }
        }
        
        private static ResourceManager _Manager;
    }
    
}

